/*
package erQiao.yfl.app.controller.login;

import java.io.File;
import java.io.UnsupportedEncodingException;
import java.util.HashMap;
import java.util.Map;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import erQiao.yfl.app.common.Result;
import erQiao.yfl.app.common.constant.LoginConstants;
import erQiao.yfl.app.common.po.ResultParamMap;
import erQiao.yfl.app.common.ro.LoginRegister;
import erQiao.yfl.app.common.ro.NewRegisterByPhone;
import erQiao.yfl.app.dao.entity.StudentEntity;
import erQiao.yfl.app.dao.entity.TeacherEntity;
import erQiao.yfl.app.service.service.SmsService;
import erQiao.yfl.app.service.service.StudentLoginRService;
import erQiao.yfl.app.service.service.TeacherService;
import erQiao.yfl.app.service.util.CacheClusterClient;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import redis.clients.jedis.Jedis;

*/
/**
 * Created by xiang.yu on 2017/3/27.
 *//*

@Controller
@RequestMapping("lr")
public class LoginAuthControl {
    private Logger logger = LoggerFactory.getLogger(LoginAuthControl.class);
    @Resource
    private SmsService smsServiceImpl;
    @Resource
    private CacheClusterClient cacheClusterClient;

    @ResponseBody
    @RequestMapping("/login")
    public Result login(HttpServletRequest request, HttpServletResponse response, @RequestBody LoginRegister loginRegister) throws UnsupportedEncodingException {

        Jedis jedis = cacheClusterClient.getRedis();

        //todo
        if(studentLoginRServiceImpl.checkLogin(loginRegister) == 1){
        }
        return resultParamMap;
    }
//
//    @RequestMapping(value = "/registerEmail", method = RequestMethod.POST)
//    public String register(HttpServletRequest request, HttpServletResponse response, @RequestBody BaseRegister baseRegister) {
//
//        //登录注册方式为邮箱
//        baseRegister.setmLoginType("2");
//        logger.info("/registerEmail |入参 baseRegister=" + baseRegister.toString());
//        if (request.getSession().getAttribute("verifyCode") != null) {
//            String valiCode = request.getSession().getAttribute("verifyCode").toString();
//            //忽略验证码大小写
//            if ((baseRegister.getValiCode().equalsIgnoreCase(valiCode))) {
//                logger.error("验证码错误！");
//            } else {
//                try {
//                    if ("st".equals(baseRegister.getType())) {
//                        studentLoginRServiceImpl.insertStu(baseRegister);
//                    } else {
//                        studentLoginRServiceImpl.insertStu(baseRegister);
//                    }
//                } catch (Exception e) {
//                    logger.error("/register,error:", e);
//                }
//            }
//        }
//        return "";
//    }

    @ResponseBody
    @RequestMapping(value = "/registerPhone", method = RequestMethod.POST)
    public Result registerPhone(HttpServletRequest request, HttpServletResponse response, @RequestBody
        NewRegisterByPhone newRegisterByPhone) {

        Jedis jedis = cacheClusterClient.getRedis();
        String code = newRegisterByPhone.getCode();
        String phoneNo = newRegisterByPhone.getPhoneNo();
        //校验手机验证码
        String hasPhoneNo = jedis.get(phoneNo);
        if(phoneNo != null && hasPhoneNo != null && hasPhoneNo.equals(code)){
            try {
                //todo 去查询是否注册过
                if(studentLoginRServiceImpl.select(newRegisterByPhone.getPhoneNo()) > 0){
                    return Result.wrapErrorResult("-1","该手机号已经注册");
                }
                //todo insert
            } catch (Exception e){
                e.printStackTrace();
            }

        } else{
            return Result.wrapErrorResult("-1","手机验证码不正确");
        }
        return Result.wrapSuccessResult(null);
    }

    //@ResponseBody
    //@RequestMapping(value = "/activate", method = RequestMethod.GET)
    //public String activate(HttpServletRequest request, HttpServletResponse response) {
    //    String activeCode = request.getParameter("code");
    //    Map map = new HashMap();
    //    map.put("activeCode",activeCode);
    //    map.put("mStatus",1);
    //    studentLoginRServiceImpl.active(map);
    //    return "";
    //}
    private static boolean deleteDir(File dir) {
        if (dir.isDirectory()) {
            String[] children = dir.list();
            //递归删除目录中的子目录下
            for (int i=0; i<children.length; i++) {
                boolean success = deleteDir(new File(dir, children[i]));
                if (!success) {
                    return false;
                }
            }
        }
        // 目录此时为空，可以删除
        return dir.delete();
    }

}
*/
